﻿@{
    ViewBag.Title = "ContractExpenseList";
    Layout = "~/Views/Shared/_UserPage.cshtml";
}
<script type="text/javascript">
    $(function () {
        //当页面首次刷新的时候执行的事件
        $("#ProjectID").combobox({
            editable: false, panelHeight: "auto",
            valueField: 'ID',
            textField: 'ProjectName',
            url: '/ProjectInfo/ProjectInfoListForFlow',
            onLoadSuccess: function () {
                var data = $("#ProjectID").combobox('getData');
                if (data.length > 0) {
                    $("#ProjectID").combobox('select', data[0]["ID"]);
                }
                else {
                    initTable('');
                }
            },
            onSelect: function (record) {
                initTable(record.ID);
            }
        });
    });

    function initTable(projectID) {
        $('#contractExpenseTreeGrid').treegrid({
            url: '/Expense/GetContractExpenseList?projectID=' + projectID,//一个用以从远程站点请求数据的超链接地址
            nowrap: true,
            autoRowHeight: false,
            singleSelect: true,
            striped: true,
            pagination: false,
            rownumbers: true,
            remoteSort: false,
            idField: 'ID',
            treeField: 'ContractName',
            parentField: 'DisplayPID',
            fitColumns: true,
            columns: [[
                        { title: 'ProjectID', field: 'ProjectID', hidden: true },
                        { title: 'ContractID', field: 'ContractID', hidden: true },
                        { title: 'ContractSource', field: 'ContractSource', hidden: true },
                        { title: '合同名称', field: 'ContractName', width: 400, sortable: true },
                        { title: '合同总额', field: 'ContractMoney', align: 'right', width: 100, sortable: true },
                        { title: '施工图金额', field: 'ConstructionDrawMoney', align: 'right', width: 100, sortable: true },
                        { title: '变更增减金额', field: 'AlterIncreaseOrDecreaseMoney', align: 'right', width: 100, sortable: true },
                        { title: '变更后金额', field: 'AfterAlterMoney', align: 'right', width: 100, sortable: true },
                        { title: '已审批付款', field: 'ApprovalMoney', align: 'right', width: 100, sortable: true },
                        { title: '审批付款比例', field: 'PaymentPercentage', align: 'right', width: 100, sortable: true },
            ]],
            onDblClickRow: function (rowData) {
                if (rowData.ContractSource != "") {
                    showMyWindow("#myWindow", "", "/Expense/ExpenseList?MenuCode=ExpenseList&projectID=" + rowData.ProjectID + "&contractID=" + rowData.ContractID + "&contractName=" + rowData.ContractName + "&contractSource=" + rowData.ContractSource + "&contractMoney=" + rowData.ContractMoney + "&constructionDrawMoney=" + rowData.ConstructionDrawMoney + "&alterIncreaseOrDecreaseMoney=" + rowData.AlterIncreaseOrDecreaseMoney + "&afterAlterMoney=" + rowData.AfterAlterMoney + "&approvalMoney=" + rowData.ApprovalMoney + "&paymentPercentage=" + rowData.PaymentPercentage, 1000, 500, true, true, true);
                }
            }
        });
    }


    function cancelPopWindow() {
        colseMyWindow("#myWindow");
    }

    function CloseAndRefreshWindow() {
        colseMyWindow("#myWindow");
        initTable();
    }
</script>
<div class="easyui-layout" fit="true">
    <div data-options="region:'north'" style="height:35px;">
        <table style="margin-top: 5px">
            <tr>
                <td style="width: 95px; text-align: center">项目名称</td>
                <td>
                    <input id="ProjectID" name="ProjectID" class="easyui-combobox" style="width: 300px;" />
                </td>
            </tr>
        </table>
    </div>

    <div data-options="region:'center'">
        <table id="contractExpenseTreeGrid" fit="true"></table>
    </div>
</div>
